package com.zhixi100.productservice.controller;

import com.zhixi100.framework.common.ObjectRestResponse;
import com.zhixi100.framework.utils.RestResponseUtils;
import com.zhixi100.productservice.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * author:tommy
 * date:2018/12/13
 */
@RestController
@RequestMapping("/v1")
public class ProductController {

    @Autowired
    private ProductService productService;

    @GetMapping("/find/product/{productId}")
    public ObjectRestResponse findProduct(@PathVariable("productId") int productId){
        ObjectRestResponse result = RestResponseUtils.success();
        result.setData(productService.findById(productId));
        return result;
    }

    @GetMapping("/update/product/{productId}")
    public ObjectRestResponse updateProduct(@PathVariable("productId") int productId){
        ObjectRestResponse result = RestResponseUtils.success();
        productService.reduceStore(productId);
        return result;
    }
}
